<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <h:head>
        <title>MeteoCal - #{eBean.eventFromId(eBean.newEvent.id).title}</title>
        <link href="../css/application.css" rel="stylesheet"></link>
        <link rel="icon" type="image/ico" href="../images/logoico.ico"/>
        <f:metadata>
            <f:viewParam name="id" value="#{eBean.newEvent.id}" />
        </f:metadata>
    </h:head>
    <h:body><div id="body">

            <div id="head">
                <a href="personalpage.xhtml"><img src="../images/logo.png" /></a>

                <h:form><p:commandLink action="#{loginBean.logout()}">
                        <p:graphicImage value="../images/logout.png" style="width: 70px; top:140px; left:88%;"/>
                    </p:commandLink></h:form>
            </div>

            <div id="title">
                <p1>MeteoCal</p1><br />
                <p2>Your website to plan your events.</p2>
            </div>

            <div id="bar">
                <a href="personalpage.xhtml" id="ppage" >#{uBean.actualLoggedUser.username} 's MeteoCal</a>
                <a href="calendar.xhtml" id="calendar">Calendar</a>
                <a href="search.xhtml" id="search">Search MeteoCal's friends</a>
            </div>

            <div id="registration"><br /><center>
                    <h:form>
                        Event organized by 
                        <b><h:link value="#{eBean.eventFromId(eBean.newEvent.id).organizer.username}" outcome="calendar"
                                      rendered="#{eBean.eventFromId(eBean.newEvent.id).organizer.username.equals(uBean.actualLoggedUser.username)}" />
                        <h:link value="#{eBean.eventFromId(eBean.newEvent.id).organizer.username}" outcome="user"
                                      rendered="#{!(eBean.eventFromId(eBean.newEvent.id).organizer.username.equals(uBean.actualLoggedUser.username))}">
                            <f:param name="user" value="#{eBean.eventFromId(eBean.newEvent.id).organizer.username}" />
                        </h:link></b>
                        <br /><br />
                        <b style="font-size: 30px;">#{eBean.eventFromId(eBean.newEvent.id).title}</b>
                        <br />
                        #{eBean.eventFromId(eBean.newEvent.id).description}
                        <br />
                        #{eBean.stringDate(eBean.newEvent.id)} from #{eBean.stringBHour(eBean.newEvent.id)}
                        to #{eBean.stringEHour(eBean.newEvent.id)}
                        <br />
                        @ #{eBean.eventFromId(eBean.newEvent.id).city} : the event is 
                        <h:outputFormat value="outdoor" rendered="#{eBean.eventFromId(eBean.newEvent.id).outdoor==true}" />
                        <h:outputFormat value="indoor" rendered="#{eBean.eventFromId(eBean.newEvent.id).outdoor==false}" />
                        <br /><br />
                        <h:form rendered="#{eBean.isWeatherNotAvailable(eBean.eventFromId(eBean.newEvent.id).city, eBean.eventFromId(eBean.newEvent.id).date)}">Weather forecast not available.</h:form>
                        <h:form rendered="#{eBean.isWeatherAvailable(eBean.eventFromId(eBean.newEvent.id).city, eBean.eventFromId(eBean.newEvent.id).date)}"> 
                        Weather Forecast : #{eBean.getWeatherMain(eBean.eventFromId(eBean.newEvent.id).city, eBean.eventFromId(eBean.newEvent.id).date)} <img src="#{eBean.getWeatherIcon(eBean.eventFromId(eBean.newEvent.id).city, eBean.eventFromId(eBean.newEvent.id).date)}" align="center" />
                        <br/>
                        Temperature : Max #{eBean.getWeatherMaxTemp(eBean.eventFromId(eBean.newEvent.id).city, eBean.eventFromId(eBean.newEvent.id).date)} F, Min #{eBean.getWeatherMinTemp(eBean.eventFromId(eBean.newEvent.id).city, eBean.eventFromId(eBean.newEvent.id).date)} F
                        <br/>
                        </h:form>
                        <br />
                        <h:body rendered="#{eBean.notHappened(eBean.newEvent.id)}">
                        <h:form rendered="#{eBean.usersCheNonJoin(eBean.newEvent.id)}">
                            Only #{eBean.eventFromId(eBean.newEvent.id).organizer.username} joins the event.</h:form>
                            
                        <h:form rendered="#{eBean.usersCheJoin(eBean.newEvent.id)}">
                            Users who join the event are #{eBean.eventFromId(eBean.newEvent.id).organizer.username}
                        <ui:repeat value="#{eBean.acceptedUsers(eBean.newEvent.id)}" var="user" class="invited">
                            , <h:link value="#{user}" outcome="user" style="font-weight: bold;">
                                <f:param name="user" value="#{user}"/>
                            </h:link>
                        </ui:repeat>
                        </h:form></h:body>
                        
                        <h:body rendered="#{eBean.yetHappened(eBean.newEvent.id)}">
                        <h:form rendered="#{eBean.usersCheNonJoin(eBean.newEvent.id)}">
                            Only #{eBean.eventFromId(eBean.newEvent.id).organizer.username} joined the event.</h:form>
                            
                        <h:form rendered="#{eBean.usersCheJoin(eBean.newEvent.id)}">
                            Users who joined the event are #{eBean.eventFromId(eBean.newEvent.id).organizer.username}
                        <ui:repeat value="#{eBean.acceptedUsers(eBean.newEvent.id)}" var="user" class="invited">
                            , <h:link value="#{user}" outcome="user" style="font-weight: bold;">
                                <f:param name="user" value="#{user}"/>
                            </h:link>
                        </ui:repeat>
                        </h:form></h:body>
                        
                    </h:form>

                <h:form rendered="#{eBean.notHappened(eBean.newEvent.id)}">
                <h:form rendered="#{eBean.uIsOrg(uBean.actualLoggedUser.username, eBean.newEvent.id)}">
                Not alone? You can invite other users!
                <br />
                                <p:panelGrid columns="2" class="table">
                <p:commandButton value="Invite users" action="#{eBean.invite()}"  
                                           style="border:0; box-shadow:0px 2px 5px #000000;">
                <f:param name="id" value="#{eBean.newEvent.id}" />
                </p:commandButton>
                
                <p:commandButton value="Modify" action="#{eBean.modif()}"  
                                           style="border:0; box-shadow:0px 2px 5px #000000;">
                <f:param name="id" value="#{eBean.newEvent.id}" />
                </p:commandButton>
                </p:panelGrid>
                </h:form>
                
                    <h:body rendered="#{iBean.ceuninvito(uBean.actualLoggedUser, eBean.eventFromId(eBean.newEvent.id))}">
                <h:form rendered="#{eBean.uNotOrg(uBean.actualLoggedUser.username, eBean.newEvent.id)}">
                                            
                <p:button value="Join" outcome="invite" style="list-style: none; border:0; box-shadow:0px 2px 5px #000000;">
                <f:param name="id" value="#{eBean.seeInvite(uBean.actualLoggedUser.username, eBean.newEvent.id)}" />
                </p:button>
                </h:form>
                    </h:body>
                </h:form>
                 
                </center>
            </div>

        </div>      
    </h:body>
</html>